home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Rexx / AskDownload.term next >
Text File  |  1995-02-20  |  2KB  |  82 lines

  1. /* $VER: AskDowload.term (20.1.95)
  2. **
  3. ** Written by Olaf `Olsen' Barthel
  4. **
  5. ** You can put this script into the `Binary dowload' text entry field
  6. ** of the transfer settings. When a download is invoked, you will be
  7. ** asked if you only want to receive files or if you want to both receive
  8. ** and send data. Depending on what you choose the Hydracom protocol
  9. ** will be invoked.
  10. **
  11. ** NOTE: In order for this script to work it must be able to find
  12. **       the Hydracom program. Change the line that reads `hydra = "hydracom"'
  13. **       if necessary, e.g. into `hydra = "c:hydracom"' or where ever you
  14. **       put the program.
  15. */
  16.  
  17. hydra = "hydracom"
  18.  
  19. OPTIONS results
  20.  
  21. ARG parameters
  22.  
  23. requestresponse options '"Receive|Receive & Send|Cancel"' prompt '"Do you wish to receive, or receive & send files?"'
  24. /*requestresponse options '"Nur empfangen|Auch versenden|Abbrechen"' prompt '"Dateien nur empfangen, oder auch versenden?"'*/
  25.  
  26. IF RC = 0 THEN DO
  27.     IF result = 1 THEN DO
  28.         cmd = "run " || hydra || " " || parameters || " get"
  29.     END; ELSE DO
  30.         requestfile title '"Select files to send"' multi stem names
  31. /*        requestfile title '"Zu verschickende Dateien wählen"' multi stem names*/
  32.  
  33.         IF RC = 0 THEN DO
  34.             plus = " send"
  35.  
  36.             DO i = 0 TO names.count - 1
  37.                 plus = plus || " " || FixName(names.i)
  38.             END
  39.  
  40.             cmd = "run " || hydra || " " || parameters || plus
  41.         END; ELSE DO
  42.             EXIT
  43.         END
  44.     END
  45.  
  46.     ADDRESS command cmd
  47. END
  48.  
  49. EXIT
  50.  
  51. FixName: PROCEDURE
  52. PARSE ARG name
  53.  
  54. blanks = 0
  55. quotes = 0
  56. chars = length(name)
  57.  
  58. DO i = 1 TO chars
  59.     c = substr(name,i,1)
  60.  
  61.     IF c = ' ' THEN blanks = blanks + 1;
  62.     IF c = '"' THEN quotes = quotes + 1;
  63. END
  64.  
  65. IF blanks > 0 THEN DO
  66.     result = '"'
  67. END; ELSE DO
  68.     result = ''
  69. END
  70.  
  71. DO i = 1 TO chars
  72.     c = substr(name,i,1)
  73.  
  74.     IF c = '"' THEN result = result || '*';
  75.  
  76.     result = result || c
  77. END
  78.  
  79. IF blanks > 0 THEN result = result || '"';
  80.  
  81. RETURN result
  82.